function val = get_pulse(x)

if x<0 || x>2
    val = 0;
elseif x>=0 && x<=1
    val = x;
elseif  x>1 && x<=2
    val = 2 - x;
else
    disp('ERROR in range');
end

end